package com.xzh.api;

import com.xzh.service.DashboardService;
import com.xzh.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.transform.Result;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/dashboard")
public class DashboardApi {
    private DashboardService dashboardService;

    @Autowired
    public void setDashboardService(DashboardService dashboardService){
        this.dashboardService = dashboardService;
    }

    @GetMapping("/stats")
    public ResponseEntity<JsonResult<Map<String,Object>>> getDashboardStats(){
        Map<String,Object> stats = dashboardService.counts();
        return ResponseEntity.ok(JsonResult.success(stats));
    }
}
